<div class="form">
<style type="text/css">
.sortable { list-style-type: none; margin: 20px 0; padding: 0; margin}
{if count($fields)>10}
.sortable li { margin: 5px 2px 2px 12px;padding:5px; padding: 5px 10px;float: left;text-align: left;}
{else}
.sortable li { margin: 5px 2px 2px 12px;padding:5px; padding: 5px 10px;width:200px;text-align: left;}
{/if}
.sortable li span { position: absolute; margin-left: -1.3em; }
input[type="radio"], input[type="checkbox"] {
    margin: 4px 0 0;
    margin-top: 1px \9;
    line-height: normal;
    vertical-align: top;
}	
</style>
<form action="{{$this->Html->url('/admin/'.$current_controller.'/list.json?export=true')}}" target="_blank" method="post">

	<label><input type="checkbox" checked="checked"  id="check-all"> 全选 </label>
	<div class="alert alert-warning">勾选需要导出的字段，可拖动调整各字段的顺序</div>
	<textarea type="hidden" name="filters" style="display:none;">{{$_REQUEST['filters']}}</textarea>
	<input type="hidden" name="_search" value="true">
<ul class="sortable clearfix">
<?PHP
	foreach($fields as $key=> $value)
	{
		echo '<li id="'.$modelClass.'_'.$value['I18nfield']['id'].'" data-field="'.$value['I18nfield']['name'].'" class="ui-state-default">

		<label><input checked="checked" type="checkbox" name="fields[]" value="'.$value['I18nfield']['name'].'"> <div style="display:inline-block;margin-left:5px;width:156px;height:32px;overflow:hidden;">'.$value['I18nfield']['translate'].'<br/>'.$value['I18nfield']['name'].'</div></label></li>';
	}
?>
</ul>
<input type="submit" class="btn btn-primary" value="{{__('Export')}}">
</form>
</div>

<script>
$(document).ready(function() {	

	$('#check-all').click(function(){
		if(this.checked) {
			$(this.form).find('input[type="checkbox"]').attr('checked',true);
		}
		else{
			$(this.form).find('input[type="checkbox"]').attr('checked',false);
		}
	});
	$(".sortable").sortable({		
		placeholder: 'ui-state-highlight'
	});
	$(".sortable").disableSelection();
});
</script>
